#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>

int main()
{
	int n;
	int t;
	
	scanf("%d", &t);
	int* price;
	price = (int*)malloc(sizeof(int) * t);
	for (int i = 0; i < t; i++) {
		scanf("%d", &price[i]);
		}

	for (int j = 0; j < t; j++) {
		 n = price[j];
		 int sum = 1;
		for (; n > 9; n/=10) {
			sum *= 10;
		}
		printf("%d\n", price[j] - sum);
	}
	free(price);
	return 0;
}



